package algri;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

public class AnaSearch {
	
	
	//查询——仅限定在前端传输起始时间和终止时间的情况下
	public List<HashMap<String, String>> reqtime_coordinate(List<HashMap<String,String>> list,String start_time,
			String stop_time) throws Exception{
		System.out.println("进入仅时间查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String>map=new HashMap<String,String>();
			String quakaTimeString=list.get(i).get("quackTime");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			Date date1=df.parse(quakaTimeString);
			Date startDate=df.parse(start_time);
			Date stopDate=df.parse(stop_time);
			if(date1.before(stopDate)&&date1.after(startDate)) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询——前端传输起始时间和终止时间 + 震级 查询震级
	public List<HashMap<String, String>> reqtl_coordinate(List<HashMap<String,String>> list,String start_time,
			String stop_time,String quakelevel) throws Exception{
		System.out.println("进入时间加震级查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String>map=new HashMap<String,String>();
			String quakaTimeString=list.get(i).get("quackTime");
			String quakaGradeString=list.get(i).get("quackGrade");
			Boolean dayuBoolean;
			double dquakelevel=Double.valueOf(quakelevel);
			double dquackGrade=Double.valueOf(quakaGradeString);
			if (dquackGrade>dquakelevel) {
				dayuBoolean=true;
			}else {
				dayuBoolean=false;
			}
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			Date date1=df.parse(quakaTimeString);
			Date startDate=df.parse(start_time);
			Date stopDate=df.parse(stop_time);
			if(date1.before(stopDate)&&date1.after(startDate)&&dayuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询——前端传递 起始时间+终止时间 +能量  
	public List<HashMap<String, String>> reqte_coordinate(List<HashMap<String,String>> list,String start_time,
			String stop_time,String energyString) throws Exception{
		System.out.println("进入时间加能量查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String>map=new HashMap<String,String>();
			String quakaTimeString=list.get(i).get("quackTime").trim();
			String quakaenergy=list.get(i).get("nengliang").trim();
			Boolean dayuBoolean;
//			int front_energy=Integer.valueOf(energyString);
//			int quackEnergy=Integer.valueOf(quakaenergy);
			double front_energy=Double.valueOf(energyString);
			double quackEnergy=Double.valueOf(quakaenergy);
			if (quackEnergy>front_energy) {
				dayuBoolean=true;
			}else {
				dayuBoolean=false;
			}
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			Date date1=df.parse(quakaTimeString);
			Date startDate=df.parse(start_time);
			Date stopDate=df.parse(stop_time);
			if(date1.before(stopDate)&&date1.after(startDate)&&dayuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询——仅按照能量查询
	public List<HashMap<String, String>> reqe_coordinate(List<HashMap<String, String>> list,String energy){
		System.out.println("进入仅能量查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for(int i=0;i<list.size();i++) {
			HashMap<String, String> map=new HashMap<String,String>();
			String quackEnergy=list.get(i).get("nengliang").trim();
			double front_energy=Double.valueOf(energy);
			double quack_energy=Double.valueOf(quackEnergy);
			Boolean dayuBoolean;
			if (quack_energy>front_energy) {
				dayuBoolean=true;
			}else {
				dayuBoolean=false;
			}
			if (dayuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询——查询震级方法
	public List<HashMap<String, String>> reql_coordinate(List<HashMap<String, String>> list,String zhenjiString){
		System.out.println("进入仅震级查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for(int i=0;i<list.size();i++) {
			HashMap<String, String> map=new HashMap<String,String>();
			String quakaGrade=list.get(i).get("quackGrade");
			Boolean dayuuBoolean=true;
			double dquakelevel=Double.valueOf(zhenjiString);
			double dquackGrade=Double.valueOf(quakaGrade);
			if (dquackGrade>dquakelevel) {
				dayuuBoolean=true;
			}else {
				dayuuBoolean=false;
			}
			if (dayuuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询—— 查询震级与能量并列查询方法
	public List<HashMap<String, String>> reqel_coordinate(List<HashMap<String,String>> list,String zhenjiString,
			String energyString) throws Exception{
		System.out.println("进入震级加能量查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String>map=new HashMap<String,String>();
			String quakaGrade=list.get(i).get("quackGrade").trim();
			String quakaenergy=list.get(i).get("nengliang").trim();
			Boolean dayuBoolean;
//			int front_energy=Integer.valueOf();
//			int quackEnergy=Integer.valueOf();
			double front_energy=Double.valueOf(energyString);
			double quackEnergy=Double.valueOf(quakaenergy);
			if (quackEnergy>front_energy) {
				dayuBoolean=true;
			}else {
				dayuBoolean=false;
			}
			Boolean dayuuBoolean=true;
			double dquakelevel=Double.valueOf(zhenjiString);
			double dquackGrade=Double.valueOf(quakaGrade);
			if (dquackGrade>dquakelevel) {
				dayuBoolean=true;
			}else {
				dayuBoolean=false;
			}
			if(dayuuBoolean&&dayuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
			}
		}
		return list1;
	}
	
	//查询——所有条件都已填写
	public List<HashMap<String, String>> reqall_coordinate(List<HashMap<String,String>> list,String zhenjiString,
			String energyString,String start_time,String end_time) throws Exception{
		System.out.println("进入震级+能量+时间查询方法");
		List<HashMap<String, String>> list1=new ArrayList<HashMap<String,String>>();
		list1.clear();
		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String>map=new HashMap<String,String>();
			String quakaGrade=list.get(i).get("quackGrade");
			String quakaenergy=list.get(i).get("nengliang");
			String quakaTimeString=list.get(i).get("quackTime");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			Date date1=df.parse(quakaTimeString);
			Date startDate=df.parse(start_time);
			Date stopDate=df.parse(end_time);
			
			Boolean dayuBoolean;
			double front_energy=Double.valueOf(energyString);
			double quackEnergy=Double.valueOf(quakaenergy);
			if (quackEnergy>front_energy) {
				dayuBoolean=true;
			}else {
//				break;
				dayuBoolean=false;
			}
			Boolean dayuuBoolean = true;
			double dquakelevel=Double.valueOf(zhenjiString);
			double dquackGrade=Double.valueOf(quakaGrade);
			if (dquackGrade>dquakelevel) {
				dayuBoolean=true;
			}else {
//				break;
				dayuBoolean=false;
			}
			if(date1.before(stopDate)&&date1.after(startDate)) {
				if (dayuuBoolean&&dayuBoolean) {
				String xString=list.get(i).get("x");
				String yString=list.get(i).get("y");
				map.put("x", xString);
				map.put("y", yString);
				list1.add(map);
				}
			}
		}
		return list1;
	}
	

}
